<?php
/**
 * Created by PhpStorm.
 * User: Ysll <754060604@qq.com>
 * Date: 2017/10/11
 * Time: 14:15
 */

namespace Admin\Model;


class Introduction extends Model
{
    protected $tableName = 'introduction';

    /**
     * 获取分类
     *
     * @return array|null
     */
    public static function getTypes()
    {
        return static::getInstance()->field('id, type')->group('type')->select();
    }

    /**
     * 通过type获取数据
     *
     * @param $type
     * @return array|null
     */
    public static function getByTypeName($type)
    {
        return static::getInstance()->where("type = '$type'")->order('created_at desc')->select();
    }

    public static function findByTitle($title)
    {
        return self::getInstance()->where("title = '$title'")->find();
    }
}